class Tab {
    constructor(id) {
        this.main = document.querySelector(id);
        this.tabs = this.main.querySelectorAll('.tab');
    }
    init() {
        // 初始化操作让相关的元素绑定事件
        for (var i = 0; i < this.tabs.length; i++) {
            ((i) => {
                this.tabs[i].addEventListener('click', function () {
                    console.log(i);
                });
            })(i);
            // const that = this;
            // (function (x) {
            //     that.tabs[x].addEventListener('click', function () {
            //         console.log(x);
            //     });
            // })(i);
        }
    }
}
const tabInstance = new Tab('#container');
tabInstance.init();